
const { resolve } = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  mode: 'development',
  entry: resolve(__dirname, 'src/app.js'),
  output: {
    path: resolve(__dirname, 'bulid'),
    filename: 'app.[hash:16].js'
  },
  devtool: 'source-map',
  module: {
    rules: [
      {
        test: /\.tpl$/,
        use: [
          // 配置自己写的loader 模板转字符串后 需要babel 转JSES6
          'babel-loader', 
          {
            loader: resolve(__dirname, 'loaders/tpl-loader'),
            options: {
              log: true
            }
          }
        ]
      }
    ]
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: resolve(__dirname, 'index.html')
    })
  ],
  devServer: {
    port: 3333,
    open: true
  }
}

